<template>
  <div class="login-page">
    <UserForm @onSubmit = "onSubmit"></UserForm>
  </div>

</template>

<script>
import { login } from '@/api/user'
import UserForm from '@/components/UserForm.vue'
import { setToken } from '@/utils/storage'

export default {
  name: 'LoginPage',
  components: {
    UserForm
  },
  data () {
    return {
      username: 'zhousg',
      password: '123456'
    }
  },
  methods: {
    async onSubmit (values) {
      const res = await login(values)
      setToken(res.data.token)
      this.$router.push({ path: '/' })
      // localStorage.setItem('token', res.data.token)
    }
  }
}
</script>
